<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>系统设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">
						<i class="fa fa-pencil"></i> 商家设置
						<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
					</div>
          <div class="layui-card-body" pad15>
            <div class="layui-form">
							<input type="hidden" name="info[id]" value="{$info.id}"/>
							<div class="layui-form-item">
								<label class="layui-form-label">商户名称：</label>
								<div class="layui-form-mid" style="width:200px;color:#333">{$info.name}</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">客服电话：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[tel]" class="layui-input" value="{$info.tel}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">客服链接：</label>
								<div class="layui-input-inline" style="width:300px">
									<input type="text" name="info[kfurl]" value="{$info.kfurl}" class="layui-input"/>
								</div>
								<div class="layui-form-mid layui-word-aux">商品详情页客服链接，不填写则使用商城内部客服系统</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商家主图：</label>
								<input type="hidden" name="info[logo]" id="logo" lay-verType="tips" class="layui-input" value="{$info.logo}">
								<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="logo" upload-preview="logoPreview" onclick="uploader(this)">上传图片</button>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：640×640像素</div>
								<div id="logoPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
									<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.logo}"/></div></div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商家照片：</label>
								<input type="hidden" name="info[pics]" value="{$info['pics']}" id="pics">
								<button style="float:left;" type="button" class="layui-btn layui-btn-primary" onclick="uploader(this,true)" upload-input="pics" upload-preview="picList" >批量上传</button>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：600*340像素</div>
								<div id="picList" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
									{if $info['pics']}
									{php}$pics = explode(',',$info['pics']);{/php}
									{foreach $pics as $pic}
									<div class="layui-imgbox">
										<a class="layui-imgbox-close" href="javascript:void(0)" onclick="$(this).parent().remove();getpicsval('pics','picList')" title="删除"><i class="layui-icon layui-icon-close-fill"></i></a>
										<span class="layui-imgbox-img"><img src="{$pic}" onclick="previewImg('{$pic}')"></span>
									</div>
									{/foreach}{/if}
								</div>
							</div>
							<!-- <div class="layui-form-item">
								<label class="layui-form-label">摘要：</label>
								<div class="layui-input-inline" style="width:700px">
									<input type="text" name="info[subname]" class="layui-input" value="{$info.subname}">
								</div>
							</div> -->
							<!-- <div class="layui-form-item">
								<label class="layui-form-label">服务标签：</label>
								<div class="layui-input-inline" style="width:400px">
									<input type="text" name="info[fuwupoint]" class="layui-input" value="{$info.fuwupoint}">
								</div>
								<div class="layui-form-mid layui-word-aux">多个用空格隔开,如: 7天退换 48小时发货 假一赔十</div>
							</div> -->
							<div class="layui-form-item">
								<label class="layui-form-label">商家简介：</label>
								<div class="layui-input-inline" style="width:500px;">
									<script id="content" name="info[content]" type="text/plain" style="width:100%;height:500px">{$info.content}</script>
									<!-- <textarea name="info[content]" class="layui-textarea" style="height:250px">{$info.content}</textarea> -->
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">商家地址：</label>
								<div class="layui-input-inline" style="width:500px">
									<input type="text" id="address" name="info[address]" class="layui-input" value="{$info.address}">
								</div>
								<button class="layui-btn layui-btn-primary" id="searchbtn">搜索</button>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"></label>
								<div id="l-map" style="width:600px;height:350px">地图加载中...</div>
								<div style="margin-left:110px;margin-top:10px">
									<div class="layui-input-inline" style="width:200px">
										<input type="text" name="info[longitude]" id="mapjd" class="layui-input" value="{$info.longitude|default='116.39782905578613'}"/>
									</div>
									<div class="layui-input-inline" style="width:200px">
										<input type="text" name="info[latitude]" id="mapwd" class="layui-input" value="{$info.latitude|default='39.90358020251377'}"/>
									</div>
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">营业时间：</label>
								<div class="layui-input-inline" style="width:120px">
									<input type="text" name="info[start_hours]" class="layui-input" value="{$info.start_hours}" id="start_hours" autocomplete="off">
								</div>
								<div class="layui-form-mid">到</div>
								<div class="layui-input-inline" style="width:120px">
									<input type="text" name="info[end_hours]" class="layui-input" value="{$info.end_hours}" id="end_hours" autocomplete="off">
								</div>
								<div class="layui-input-inline" style="width:120px;clear:left;margin-left:110px">
									<input type="text" name="info[start_hours2]" class="layui-input" value="{$info.start_hours2}" id="start_hours2" autocomplete="off">
								</div>
								<div class="layui-form-mid">到</div>
								<div class="layui-input-inline" style="width:120px">
									<input type="text" name="info[end_hours2]" class="layui-input" value="{$info.end_hours2}" id="end_hours2" autocomplete="off">
								</div>
								<div class="layui-input-inline" style="width:120px;clear:left;margin-left:110px">
									<input type="text" name="info[start_hours3]" class="layui-input" value="{$info.start_hours3}" id="start_hours3" autocomplete="off">
								</div>
								<div class="layui-form-mid">到</div>
								<div class="layui-input-inline" style="width:120px">
									<input type="text" name="info[end_hours3]" class="layui-input" value="{$info.end_hours3}" id="end_hours3" autocomplete="off">
								</div>
								<div class="layui-form-mid layui-word-aux" style="clear:left;margin-left:110px">结束时间小于或等于开始时间表示跨天,如:00:00到00:00点表示全天营业,16:00到06:00表示下午4点到次日早晨6点</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">微信号：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[weixin]" class="layui-input" value="{$info.weixin}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">支付宝：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[aliaccount]" class="layui-input" value="{$info.aliaccount}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">开户行：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[bankname]" class="layui-input" value="{$info.bankname}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">持卡人：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[bankcarduser]" class="layui-input" value="{$info.bankcarduser}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">银行卡号：</label>
								<div class="layui-input-inline" style="width:200px">
									<input type="text" name="info[bankcardnum]" class="layui-input" value="{$info.bankcardnum}">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label" >发票开关：</label>
								<div class="layui-input-inline">
									<input type="radio" name="info[invoice]" value="1" {if $info['invoice']==1}checked{/if} title="开启" />
									<input type="radio" name="info[invoice]" value="0" {if $info['invoice']==0}checked{/if} title="关闭" />
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">发票类型：</label>
								<div class="layui-input-inline" style="width:300px">
									<input type="checkbox" name="info[invoice_type][]" value="1" title="普通发票" lay-skin="primary" {if in_array('1',$info['invoice_type'])}checked{/if}/>
									<input type="checkbox" name="info[invoice_type][]" value="2" title="增值税专用发票" lay-skin="primary" {if in_array('2',$info['invoice_type'])}checked{/if}/>
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label" >店铺状态：</label>
								<div class="layui-input-inline">
									<input type="radio" name="info[is_open]" value="1" {if $info['is_open']==1}checked{/if} title="开启" />
									<input type="radio" name="info[is_open]" value="0" {if $info['is_open']==0}checked{/if} title="关闭" />
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button class="layui-btn layui-btn-danger" lay-submit lay-filter="formsubmit">提 交</button>
								</div>
							</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
	{include file="public/js"/}
	<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=ABLBZ-4BIKU-GFTVB-BK7IK-OLQ35-QCBFF"></script>
	<script>

	layui.laydate.render({ 
		elem: '#start_hours',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#end_hours',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#start_hours2',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#end_hours2',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#start_hours3',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#end_hours3',
		type: 'time',
		format:'HH:mm',
		trigger: 'click'
	});
	
	layui.form.on('radio(changest)', function(data){
		if(data.value == '2'){
			$('#changestset').show();
		}else{
			$('#changestset').hide();
		}
	})
	var ueditor = UE.getEditor('content');
	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		field['info[content]'] = ueditor.getContent();
		//console.log(field);return;
		var index = layer.load();
		$.post("",field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					reload()
				},1000)
			}
		})
	})
  </script>
	<script>
	
	var searchService, map,markers = [],marker = null;
	var jd = $('#mapjd').val();
	var wd = $('#mapwd').val();
	window.onload=function(){
		function init(){
			var center = new qq.maps.LatLng(wd,jd);
			var map = new qq.maps.Map(document.getElementById("l-map"), {
				center: center,      // 地图的中心地理坐标。
				zoom:15              // 地图的中心地理坐标。
			});	
			var marker = new qq.maps.Marker({ position:center, map: map});
			markers.push(marker);
			 //绑定单击事件添加参数
			qq.maps.event.addListener(map, 'click', function(event) {
				clearOverlays(markers);
				$("#mapjd").val(event.latLng.getLng());
				$("#mapwd").val(event.latLng.getLat());
				var marker = new qq.maps.Marker({ position: new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng()) , map: map
				});
				markers.push(marker);
			});
			//设置Poi检索服务，用于本地检索、周边检索
			searchService = new qq.maps.SearchService({
				//设置搜索范围为北京
				location: center.lat+"," +center.lng,
				//设置搜索页码为1
				pageIndex: 1,
				//设置每页的结果数为5
				pageCapacity: 5,
				//设置展现查询结构到infoDIV上
				// panel: document.getElementById('infoDiv'),
				//设置动扩大检索区域。默认值true，会自动检索指定城市以外区域。
				autoExtend: true,
				//检索成功的回调函数
				complete: function(results) {
					//设置回调函数参数
					var pois = results.detail.pois;
					var infoWin = new qq.maps.InfoWindow({
						map: map
					});
					var latlngBounds = new qq.maps.LatLngBounds();
					for (var i = 0, l = pois.length; i < l; i++) {
						var poi = pois[i];
						//扩展边界范围，用来包含搜索到的Poi点
						latlngBounds.extend(poi.latLng);
						(function(n) {
							var marker = new qq.maps.Marker({
								map: map
							});
							marker.setPosition(pois[n].latLng);
							marker.setTitle(i + 1);
							markers.push(marker);
							qq.maps.event.addListener(marker, 'click', function() {
								$("#mapjd").val(pois[n].latLng.lng);
								$("#mapwd").val(pois[n].latLng.lat);
								infoWin.setPosition(pois[n].latLng);
							});
						})(i);
					}
					//调整地图视野
					map.fitBounds(latlngBounds);
				},
				//若服务请求失败，则运行以下函数
				error: function() {
					dialog("请先搜索省市区再搜索详细地址");
				}
			});
		}
		init();
	}
	//清除地图上的marker
    function clearOverlays(overlays) {
        var overlay;
        while (overlay = overlays.pop()) {
            overlay.setMap(null);
        }
    }
	$("#searchbtn").click(function(){
		var address = $("#address").val();
		if(address == ""){
			dialog("请输地址！");
			return ;
		}
		 clearOverlays(markers);
		//根据输入的关键字在搜索范围内检索
    searchService.search(address);
	});
	function previewImg(url){
		layer.open({type:1,area:'500px',content:'<div style="margin:auto auto;text-align:center"><img src="'+url+'" style="max-width:100%;max-height:100%"/></div>',title:false,shadeClose:true})
	}
	</script>
</body>
</html>